package top.zhangjianyong.tools.service.mybatis.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.zhangjianyong.tools.entity.Torrent;
import top.zhangjianyong.tools.mapper.TorrentMapper;
import top.zhangjianyong.tools.service.mybatis.ITorrentService;

import java.util.List;

/**
 * @author ： zhangjianyong
 * @date ： 2023/3/22 2:58 PM
 */
@Service
public class ITorrentServiceImpl extends ServiceImpl<TorrentMapper, Torrent> implements ITorrentService {

    @Override
    public Torrent qryByMd5(String md5) {
        return lambdaQuery()
                .eq(Torrent::getMd5, md5)
                .one();
    }

    @Override
    public List<Torrent> listOrderByUpdate() {
        return lambdaQuery()
                .orderByDesc(Torrent::getUpdateTime)
                .last("limit 50 ")
                .list();
    }
}
